package com.rx.substation.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import com.rx.substation.domain.RunUnitCheck;
import com.rx.substation.provider.OrderProvider;

public interface MonthCompleteStatusDAO {
	
    
    @Select("select * from run_unit_data where checkMonth >= #{start} and checkMonth <= #{end} order by stationCode")
    List<RunUnitCheck> findMonthCompleteStatus(@Param("start")String start, @Param("end")String end);
    
    @SelectProvider(type = OrderProvider.class, method = "findCompleteStatusByConditions")
    Map<String, Object> findCompleteStatusByConditions(@Param("area")String area,@Param("runUnit")String runUnit,@Param("stationTypeId")String stationTypeId,
			@Param("start")String start,@Param("end")String end,@Param("stationCode")String stationCode);

    @Select("select coefficient from run_unit_data where stationCode = #{stationCode}")
	Double getCoefficientByStationCode(@Param("stationCode")String stationCode);

    @Select("select TOP 5 StationCode,createDate from RunSubStationInstrumentAnalysisRecord a "
    		+ " LEFT JOIN Station b on b.PositionName=a.stationName where createDate >= #{start} and createDate <=#{end} and StationCode = #{stationCode}"
    		+ " ORDER BY StationCode,createDate DESC ")
    List<Map<String, Object>> getWeekCompleteStatus(@Param("start")String start,@Param("end")String end,@Param("stationCode")String stationCode);
    
    @Select("select TOP 2 StationCode,createDate from RunSubstationAQMSinstrumentMaintain a "
    		+ " LEFT JOIN Station b on b.PositionName=a.stationName where createDate >= #{start} and createDate <=#{end} and StationCode = #{stationCode}"
    		+ " ORDER BY StationCode,createDate DESC ")
	List<Map<String, Object>> getMonthCompleteStatus(@Param("start")String start,@Param("end")String end,@Param("stationCode")String stationCode);

    @Select("select TOP 2 StationCode,createDate from RunSubStationNoxConvertRecord a "
    		+ " LEFT JOIN Station b on b.PositionName=a.stationName where createDate >= #{start} and createDate <=#{end} and StationCode = #{stationCode}"
    		+ " ORDER BY StationCode,createDate DESC ")
	List<Map<String, Object>> getHalfYearCompleteStatus(@Param("start")String start,@Param("end")String end,@Param("stationCode")String stationCode);

    @Select("select TOP 2 StationCode,createDate from RunSubStationAQMSMaintainRecordYear a "
    		+ " LEFT JOIN Station b on b.PositionName=a.stationName where createDate >= #{start} and createDate <=#{end} and StationCode = #{stationCode}"
    		+ " ORDER BY StationCode,createDate DESC ")
	List<Map<String, Object>> getYearCompleteStatus(@Param("start")String start,@Param("end")String end,@Param("stationCode")String stationCode);

	

}
